package com.wh.accesscontrol.util;

import java.util.HashMap;
import java.util.Map;

public class RetUtil {

    /**
     * 成功状态
     */
    public static final int status_success = 200;

    /**
     * 请求失败状态
     */
    public static final int status_failed = 400;

    /**
     * 数据为空状态
     */
    public static final int status_null = 300;

    /**
     * 异常状态
     */
    public static final int status_error = 500;


    public static Map ret(int status, Object o) {
        Map<String, Object> t_map = new HashMap<String, Object>();
        t_map.put("status", status);
        t_map.put("ret", o);
        return t_map;
    }

    public static Map retSuccess(Object o) {
        return ret(status_success, o);
    }
    public static Map retSuccess() {
        HashMap map = new HashMap();
        map.put("code", 0);
        map.put("msg", "成功！");
        return map;
    }

    public static Map retError(Object o) {
        return ret(status_error, o);
    }

    public static Map retError() {
        HashMap map = new HashMap();
        map.put("code", 2);
        map.put("msg", "失败！");
        return map;
    }

    public static Map retFailed(Object o) {
        return ret(status_failed, o);
    }

    public static Map retNull(Object o) {
        return ret(status_null, o);
    }


}
